package com.xxx.pool;


import java.util.concurrent.*;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/8/2  9:26
 * @Copyright
 */
public class ExectorDome {
    public static void main(String[] args) {
//        //创建带缓冲区的线程池
//        final ExecutorService executorService = Executors.newCachedThreadPool();
//        executorService.submit(new Runnable() {
//            @Override
//            public void run() {
//
//            }
//        });
//        executorService.submit(() -> System.out.println("executorService = " + executorService));
//
//
//
//        //固定线程数的线程池
//        final ExecutorService executorService1 = Executors.newFixedThreadPool(10);
//        //定期的执行线程池
//        final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
//        //单个 worker 线程池
//        final ExecutorService executorService2 = Executors.newSingleThreadExecutor();

        //corePoolSize:核心线程数
        //maximumPoolSize:最大线程数

        //ArrayBlockingQueue:一个由数组支持的有界阻塞队列
        //LinkedBlockingQueue:无界队列
        //PriorityBlockingQueue:有界队列
        final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20, 1000, TimeUnit.SECONDS, new ArrayBlockingQueue<>(5));
        threadPoolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "6666666" + " + " + i);

                }
            }
        });

    }

}
